package com.cvmars.jianyou.module.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.cvmars.jianyou.R;
import com.cvmars.jianyou.api.api.Api;
import com.cvmars.jianyou.api.api.HttpUtils;
import com.cvmars.jianyou.api.api.SimpleSubscriber;
import com.cvmars.jianyou.api.model.HttpResult;
import com.cvmars.jianyou.api.model.UserMode;
import com.cvmars.jianyou.module.base.BaseActivity;
import com.cvmars.jianyou.utils.ToastUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ResetPassSetActivity extends BaseActivity {

    @BindView(R.id.txt_reset_phone)
    EditText txtResetPhone;
    @BindView(R.id.txt_reset_password)
    EditText txtResetPassword;
    @BindView(R.id.txt_reset_btn)
    Button txtResetBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_reset_pass_set);
        ButterKnife.bind(this);
    }

    @OnClick(R.id.txt_reset_btn)
    public void onViewClicked() {

        String old_password = txtResetPhone.getText().toString();
        String new_password = txtResetPassword.getText().toString();
        if (TextUtils.isEmpty(old_password)) {
            ToastUtils.show("原密码不能为空");
            return;
        }

        if (TextUtils.isEmpty(new_password)) {
            ToastUtils.show("新密码不能为空");
            return;
        }


        HttpUtils.getInstance().toSubscribe(Api.getInstance()
                        .postResetPassword(old_password, new_password)
                , new SimpleSubscriber<HttpResult<Object>>() {
                    @Override
                    protected void _onNext(HttpResult<Object> o) {

                        ToastUtils.show(o.getMsg());

                    }

                    @Override
                    protected void _onError(String message) {

                    }
                });
    }
}
